#pragma once
#include "SimpleCanvas.h"
#include "graphics/Rect.h"
#include "util/Flag.h"
#include "include/core/SkCanvas.h"

namespace yzrilyzr_simplecanvas{
	EBCLASS(Drawable){
	private:
	Rect bounds;
	yzrilyzr_util::Flag flags;
	static constexpr const int const FLAG_INVALIDATE=0b1;
	public:
	static constexpr const int const NOT_INTRINSIC=-1;
	virtual void draw(SkCanvas & canvas){}
	virtual void onBoundsChange(Rect & rect){}
	void invalidateSelf(){
		flags.add(FLAG_INVALIDATE);
	}
	bool needInvalidateAndClearFlag(){
		return flags.hasAndRemove(FLAG_INVALIDATE);
	}
	void setBounds(int32_t l, int32_t t, int32_t r, int32_t b);
	void setBounds(Rect & rect);
	Rect & getBounds();
	virtual int32_t getIntrinsicWidth(){
		return NOT_INTRINSIC;
	}
	virtual int32_t getIntrinsicHeight(){
		return NOT_INTRINSIC;
	}
	};
}